<template>
    <a-affix :offsetBottom="offsetBottom" :offsetTop="offsetTop" ref="affix">
        <slot></slot>
    </a-affix>
</template>

<script>
  import {prefix} from '../config';
  export default {
    name: `${prefix}Affix`,
    props: {
      offsetBottom: Number,
      offsetTop: Number
    },
    computed: {
      menuCollapsed () {
        return this.$store.state.view.menuCollapsed;
      }
    },
    watch: {
      menuCollapsed () {
        setTimeout(() => {
          this.updatePosition();
        }, 300);
      }
    },
    methods: {
      updatePosition (obj = {}) {
        this.$refs['affix'].updatePosition(obj);
      }
    }
  };
</script>

<style scoped>

</style>